package com.arlen.general.util;

import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Properties;

public class PropertiesUtils {
    public Properties properties;

     {
        properties = new Properties();

        // 使用ClassLoader加载properties配置文件生成对应的输入流
        InputStream in = HttpRequest.class.getClassLoader().getResourceAsStream("needed.properties");
         try {
             properties.load(in);
         } catch (IOException e) {
             e.printStackTrace();
         }
     }

    public String getProperValue(String path)  {
       if (StringUtils.isNoneBlank(path)){
           String mes = properties.getProperty(path);
           try {
               return new String(mes.getBytes("GBK"), "utf-8");//这一句是重点
           } catch (UnsupportedEncodingException e) {
               e.printStackTrace();
           }

       }
        return null;
    }

}
